home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: 100435.736@compuserve.com (David A. Mair)
- Newsgroups: comp.lang.c++
- Subject: Re: Callback Functions In C++
- Date: Mon, 15 Apr 1996 08:18:26 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4kt0ol$qdt@dub-news-svc-6.compuserve.com>
- References: <4kdrfu$kiu@morse.ukonline.co.uk>
- NNTP-Posting-Host: hd26-162.compuserve.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- andy.walsh@ukonline.co.uk wrote:
-
- >Can anyone tell me how I could code a callback function that works
- >inside a class and that I can pass the address of to the waveInOpen
- >function. It would seem that a member function carries an extra
- >'this' pointer and so cannot be addressed the same as an ordinary
- >function. Any ideas? I also tried to use Borland's response table
- >to handle the messages but it will only respond to a 'SendMessage'
- >command and not to my low level audio commands.
-
- The response you received from Dmitry covers the most important part
- of the method but I thought it would be worth adding something. If
- you use a static member function you will not have a this pointer and
- subsequently you will not be able to access any per instance member
- variables. A static member can only make use of other static members
- unless it has a way of obtaining the value of this for a particular
- instance of the class. You can do this by creating a static array of
- pointers to the class type, although you will need some other
- component to ensure that you can find the correct this pointer for the
- callback that has happened. One way might be to maintain a static
- array of Window handles with index numbers that match the index
- numbers of their associated this pointer for the class to handle the
- callback for that window. This, of course, assumes that the callbacks
- are multiple and associated with Windows.
-
- Regards
- David.
-
-